package cn.edu.neusoft.amicooldemo.model;

import cn.edu.neusoft.amicooldemo.bean.Constants;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

/**
 * Created by Junsheng on 2016/12/14.
 */

public class BaseModel {
    private static Retrofit retrofit;
    public BaseModel(){
    }
    public static <T> T createService(Class<T> serviceClass){

        retrofit = new Retrofit.Builder().baseUrl(Constants.SERVERADDRESS).addConverterFactory(GsonConverterFactory.create()).build();

        return retrofit.create(serviceClass);
    }
    public static <T> T createService(Class<T> serviceClass,String url){
        if(url.equals("scalar")){
            retrofit = new Retrofit.Builder().baseUrl(Constants.SERVERADDRESS).addConverterFactory(ScalarsConverterFactory.create()).build();
        }
        return retrofit.create(serviceClass);
    }


}
